<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <template id="my-counter">
        <div>
            <h2>计数器（子组件）</h2>
            <p>{{value}}</p>
            <button @click="$emit('input',value + 1)">值加1</button>
        </div>
    </template>
    <main id="app">
        <my-counter v-model="count"></my-counter>
        <div>
            <h2>计数器显示</h2>
            <p>子组件的值：{{count}}</p>
        </div>
    </main>
</body>
<script src="../../vue.js"></script>
<script>
    Vue.component("my-counter",{
        template: "#my-counter",
        props: ["value"],
    })


    let vue = new Vue({
        el: "#app",
        data() {
            return {
                count: 0
            }
        },
    })
</script>
</html>